package calculatorMain;

import java.awt.Color;
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

import calculatorController.DiffButton;
import calculatorController.DivButton;
import calculatorController.EqualButton;
import calculatorController.MultButton;
import calculatorController.NumbButtons;
import calculatorController.SumButton;
import calculatorModel.Operation;
import calculatorView.CalculatorArea;
import calculatorView.ExamplesUtils;

public class Main {

	public static void main(String[] args) {
		
		Operation operator = new Operation();
		
		CalculatorArea area = new CalculatorArea(operator);
		
		area.getArea().setBackground(Color.LIGHT_GRAY);
		
		JButton[] buttons = new JButton[10];
	
		
		NumbButtons buttonsctrl = new NumbButtons(area, buttons, operator);
		
		;
		JFrame frame = ExamplesUtils.createFrame();
		

		JPanel panel = new JPanel();
		panel.setLayout(new GridLayout(4,1));
		panel.add(area.getArea());
		panel.setBackground(Color.BLUE);
		
		JPanel panel1 = new JPanel();
		panel1.setLayout(new GridLayout(5, 3));
		for (int i = 0; i < buttons.length; i++) {
			panel1.add(buttonsctrl.getButtons()[i]);
		}
		

	
		panel.add(panel1);
		
		JPanel panel2 = new JPanel();
		panel2.setLayout(new GridLayout(2, 2));
		JButton eq=new SumButton(operator, area);
		eq.setForeground(Color.LIGHT_GRAY);

		eq.setBackground(Color.DARK_GRAY);
		panel2.add(eq);
		eq = new DivButton(operator, area);
		eq.setForeground(Color.LIGHT_GRAY);
		eq.setBackground(Color.DARK_GRAY);
		panel2.add(eq);

		eq = new MultButton(operator, area);
		eq.setForeground(Color.LIGHT_GRAY);
		eq.setBackground(Color.DARK_GRAY);
		//panel2.add(new DivButton(operator, area));
		panel2.add(eq);
		eq = new DiffButton(operator, area);
		eq.setForeground(Color.LIGHT_GRAY);
		eq.setBackground(Color.DARK_GRAY);
		panel2.add(eq);
		JPanel panel3 = new JPanel();
		panel3.setLayout(new GridLayout(1, 1));
		eq=new EqualButton(operator, area);
		eq.setBackground(Color.BLACK);
		panel3.add(eq);
		panel.add(panel2);
		panel.add(panel3);
		
		
		frame.setTitle("Calculator");
		frame.setSize(350, 350);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// programma
																// termina
																// quando
																// qualcuno
																// chiude la
																// finestra

		frame.getContentPane().add(panel);
		
	//	frame.getContentPane().add(area.getArea());// il contentpane è il
													// pannello dei
	
		frame.setVisible(true);

	}
}
